<?php

class CreateRepaymentBehavior extends CActiveRecordBehavior
{
	public function afterSave($event){
		if($this->owner->credit->repaymentsSum == $this->owner->credit->sum){
			$this->owner->credit->status = Credits::STATUS_CLOSED;
			$this->owner->credit->close_date = date('Y-m-d H:i:s');
			$this->owner->credit->save();
		}
	}
}